package test;

import com.demo.dao.ITestDao;
import com.jweb.annotaion.JAutowired;
import com.jweb.annotaion.JController;
import com.jweb.annotaion.JParam;
import com.jweb.core.handle.Controller;
import com.jweb.plugin.dynamicdatasource.DataSourceHolder;
import com.jweb.plugin.mybatis.plugins.MybatisInterceptor_Page;
import com.jweb.plugin.mybatis.plugins.dto.Page;

@JController("/test/mybatis")
public class MybatisPluginController extends Controller {

	public @JAutowired ITestDao dao;

	/**
	 * Mybatis插件测试
	 * 1、日志插件[ok]
	 * 2、分页插件[ok]
	 * 3、主备库联合查询插件
	 * @param curPage
	 */
	public void fenye(@JParam("${1}") int curPage) {
		Page page = new Page();
		page.setPage(curPage);
		dao.listPage(page);
		toWriterJSON(page);
	}
	
	/**
	 * oracle查询测试
	 */
	public void oracle(){
		DataSourceHolder.setDbType("oracle_db");
		MybatisInterceptor_Page.SetDBtype("oracle");//仅仅临时切换数据库类型
		toWriterText(dao.getOracleTime());
	}
}
